#coding=utf-8
import os.path

import numpy as np
import util
import  matplotlib.pyplot as plt
import pylab
import cv2
import cv2 as cv
import timeit
import sys
import time
from typing import Tuple
from util import  global_variable
from util import  getU16C3ImageFromTifAndSave2CurrentDir
import watershed

start = time.process_time()
workspace_base_dir  = "/home/hhd/workspace/longi_coal_picture/"
jing_kuang_dir = workspace_base_dir + "jingKuang"
zhong_kuang_1 = workspace_base_dir + "zhongKuang1"
zhong_kuang_2 = workspace_base_dir + "zhongKuang2"
wei_kuang_dir = workspace_base_dir + "weiKuang"
jing_kuang_dir_u16_c3  = workspace_base_dir + "jingKuang_u16_c3"
zhong_kuang_1_u16_c3 = workspace_base_dir + "zhongKuang1_u16_c3"
zhong_kuang_2_u16_c3 = workspace_base_dir + "zhongKuang2_u16_c3"
wei_kuang_dir_u16_c3 = workspace_base_dir + "weiKuang_u16_c3"
hardToDivide = workspace_base_dir +  "hardToDivide"

all_coal_dir = [jing_kuang_dir,zhong_kuang_1,zhong_kuang_2,wei_kuang_dir]

img_name = "/home/hhd/workspace/longi_coal_picture/jingKuang/505_00069_30_003.tif"



# img_name = wei_kuang_dir + "/" + "2287_00054_21_019.tif" # 假的三个图像相互粘连

# zhongkuagn2 图像2620处理，大小圈嵌套


global_variable = {}



    
tie_xin_jing = "/home/hhd/workspace/longi_coal_picture/tie_xin/jingKuang/"
tie_xin_wei = "/home/hhd/workspace/longi_coal_picture/tie_xin/weiKuang"

    # print("shape: " ,img_left_u8.shape)
    # util.cv2_imwrite("img_left_u8", img_left_u8)
    # segmentation_contours_tuple = util.distance_transform_based_watershed(img_left_u8)


    #绘制彩色图像
    # black_background = util.get_mask_from_contour(img_left_u8,segmentation_contours_tuple, -1,is_use_black_background=False,put_index=True)
    # util.imshow2("origin_img",img_left_u8,"segmentation_result",black_background)

# get_segmetation_result("/tmp/img_left_u8.png")
#  get_u16_c3_img(img_name)
#  get_segmetation_result(img_name)
#  util.exec_fun_for_files_in_dir(jing_kuang_dir,get_u16_c3_img)
#  util.exec_fun_for_files_in_dir(wei_kuang_dir,get_u16_c3_img)
util.exec_fun_for_files_in_dir(tie_xin_jing,getU16C3ImageFromTifAndSave2CurrentDir)
util.exec_fun_for_files_in_dir(tie_xin_wei,getU16C3ImageFromTifAndSave2CurrentDir)

# print(global_variable)


end = time.process_time()

print("程序运行时间: " ,end - start ," seconds" )
